﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ankh.BugNet.Extension.IssueTracker
{
    public class Issue
    {
        /// <summary>
//0	126
//1	2013/12/2 11:29:48
//2	2013/12/2 16:23:32  updated
//status 3	UnAssigned
//description 4	<p>
//	Ankn BugNet 集成工具</p>
//assigned 5	ZN  
//solution 6	none
//type 7	Idea
//title 8	Ankn BugNet 集成工具
//priority 9	Normal
//milstone 10	none
//11	Admin
//12	New Future
        /// </summary>
        public int Id { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime UpdatedAt { get; set; }
        public string Status { get; set; }
        public string Description { get; set; }
        public string AssignedUser { get; set; }
        public string Solution { get; set; }
        public string Category { get; set; }
        public string Title { get; set; }
        public string Priority { get; set; }
        public string Milestone { get; set; }
        public string Owner { get; set; }
        public string Type { get; set; }

        public object[] OriginalRow { get; private set; }

        public static Issue CovertByRow(object rowObject)
        {
            var issue = new Issue();
            var row = rowObject as object[];
            if (row == null || row.Length<13)
            {
                return issue;
            }

            issue.Id = int.Parse(row[0].ToString());
            issue.CreatedAt = DateTime.Parse(row[1].ToString());
            issue.UpdatedAt = DateTime.Parse(row[1].ToString());
            issue.Status = row[3].ToString();
            issue.Description = row[4].ToString();
            issue.AssignedUser = row[5].ToString();
            issue.Solution = row[6].ToString();
            issue.Category = row[7].ToString();
            issue.Title = row[8].ToString();
            issue.Priority = row[9].ToString();
            issue.Milestone = row[10].ToString();
            issue.Owner = row[11].ToString();
            issue.Type = row[12].ToString();
            issue.OriginalRow = row;
            return issue;
        }
    }
}
